<?php

namespace app\admin\controller;

use think\Controller;
use buildView\Form;
use buildView\Grid;
use app\common\model\ShopOpinion;

/**
 * 常见问题
 * Class Opinion
 * @package app\admin\controller
 */
class Opinion extends Controller
{
    /**
     * 列表
     * @auth true
     * @menu true
     * @return string
     */
    public function index()
    {
        $grid = new Grid(new ShopOpinion);
		$grid->column('title','标题');
		$grid->column('content','解决方案');
        $grid->column('status', '上架状态')->align('left')->switchs([
            'on' => ['text' => '启用', 'value' => 1],
            'off' => ['text' => '禁用', 'value' => 0],
        ]);
		$grid->column('create_at','添加时间');
		$grid->filter(function ($filter){
            $filter->dateBetween('create_at','添加时间');
        });
        $grid->setFromOpen();
        $grid->hideExportButton();
        $grid->actions(function ($action){
        	 $action->hideDetail();
        });
        return $grid->view();
    }

    /**
     * 添加/编辑
     * @auth true
     * @menu true
     * @return string
     */
    public function form()
    {
        $form = new Form(new ShopOpinion);
		$form->text('title','标题')->required();
		$form->ckeditor('content','解决方案')->required();
        return $form->view();
    }
}
